// 2. 有状态组件
import 'package:flutter/material.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(
          'Dio 插件',
          style: TextStyle(
            color: Colors.white,
          ),
        ),
        backgroundColor: Colors.purple,
      ),
      body: ListView.builder(
        itemBuilder: (context, index) {
          return GestureDetector(
            onTap: () {
              // 跳转路由，到详情页
              // Navigator.push(
              //   context,
              //   MaterialPageRoute(builder: (context) {
              //     return const DetailPage();
              //   }),
              // );
              Navigator.pushNamed(context, '/detail');
            },
            child: Container(
              height: 100,
              color: Colors.green,
              child: Text('这是第$index个item'),
            ),
          );
        },
        itemCount: 10,
      ),
    );
  }
}
